DEMO 1: Let's see how we can write programs that change depending on random numbers!

If statements, or conditionals, start with a test that compares a test variable to a test value. If the test statement is true, the code indented underneath runs. If the test statement is not true, the indented code is skipped and the rest of the program runs. An indent is 4 spaces, and properly indented lines will show a ···· before the line of code!

  • Click Run and follow the on-stage instructions before clicking Submit and Next to move on.

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)